// 用量接口管理
import request from "@/utils/request";

import type {
  AmountEditResponse,
  AmountPageRequest,
  AmountPageResponse,
  AmountResponse,
  AmountType,
  TasteAmountListResponse
} from "./types";

enum API {
  AMOUNT_PAGE = "/wx/amount/page",
  AMOUNT_CREATE_OR_EDIT = "/wx/amount/createOrEdit",
  AMOUNT_GET_BY_ID = "/wx/amount/getById",
  AMOUNT_REMOVE = "/wx/amount/remove",
  AMOUNT_List = "/wx/amount/list",
}

export const amountPage = (data: AmountPageRequest) =>
  request.post<any, AmountPageResponse>(API.AMOUNT_PAGE, data);

export const amountCreateOrEdit = (data: AmountType) =>
  request.post<any, AmountEditResponse>(API.AMOUNT_CREATE_OR_EDIT, data);

export const amountGetById = (id: number) =>
  request.get<any, AmountResponse>(API.AMOUNT_GET_BY_ID + `/${id}`);

export const amountRemove = (id: number) =>
  request.delete<any, AmountEditResponse>(API.AMOUNT_REMOVE + `/${id}`);

export const list = () => request.get<any, TasteAmountListResponse>(API.AMOUNT_List);